package cn.com.lushunming.rdbmserver.config;

import org.apache.commons.codec.binary.StringUtils;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.util.DigestUtils;

/**
 * 加密工具
 */
class Md5Encoder implements PasswordEncoder {
    public String encode(CharSequence charSequence) {
        return DigestUtils.md5DigestAsHex(charSequence.toString().getBytes());

    }

    public boolean matches(CharSequence charSequence, String s) {
        return StringUtils.equals(encode(charSequence), s);
    }
}
